import router from '@system.router';
import LogUtil from '../../common/baseUtil/LogUtil.js';
import BaseParseConfModel from '../../model/baseParseConfImpl/BaseParseConfModel.js';

import brightness from '@ohos.brightness';

let logUtil = new LogUtil();
let baseParseConfModel = new BaseParseConfModel();
let list = [
    {
        "settingIcon": "/res/image/icon_battery.png",
        "settingType": 1,
        "settingAlias": "aboutBattery",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/batteryPage/batteryPage"
    },
    {
        "settingIcon": "/res/image/icon_brightness.png",
        "settingType": 1,
        "settingAlias": "brightness",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/brightnessPage/brightnessPage"
    },
    {
        "settingIcon": "/res/image/icon_powermgr.png",
        "settingType": 1,
        "settingAlias": "powermgr",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/powermgrPage/powermgrPage"
    },
    {
        "settingIcon": "/res/image/icon_lock.png",
        "settingType": 1,
        "settingAlias": "lockpage",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/lockPage/lockPage"
    },
    {
        "settingIcon": "/res/image/icon_battery_statistics.png",
        "settingType": 1,
        "settingAlias": "batteryStatistics",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/statsPage/statsPage"
    },
    {
        "settingIcon": "/res/image/icon_thermal.png",
        "settingType": 1,
        "settingAlias": "thermal",
        "settingTitle": "",
        "settingValue": "",
        "settingArrow": "/res/image/ic_settings_arrow.png",
        "settingShowDivider": true,
        "settingUri": "pages/thermalPage/thermalPage"
    }
];

export default {
    data: {
        mainList: [],
        mainJsonPath: '/data/app/el1/bundle/public/com.example.powerhap/com.example.entry/assets/power/resources/rawfile/mainList.json'
    },
    onInit() {
        logUtil.info('mainListPage onInit start:');
        this.mainList = baseParseConfModel.getJsonData(this.mainJsonPath)
        this.mainList = this.mainList || list;
        logUtil.info('mainListPage onInit end:' + this.mainList);
    },
    mainListData(data) {
        logUtil.info('mainList settingListData:' + JSON.stringify(data));
        this.mainList = data;
    },
    onShow() {
        logUtil.info('mainList onShow start');
        for (let key in this.mainList) {
            var settingAlias = this.mainList[key].settingAlias
            this.mainList[key].settingTitle = this.$t('strings.'.concat(settingAlias));
        }
        logUtil.info('mainList onShow end');
    }
}